<template>
  <div>
    <Modal title="导出" v-model="exportModel1" @on-ok="comfirmExport1" @on-cancel="backoutExport">
      <div>
        <p>是否确认导出？</p>
      </div>
    </Modal>
    <Modal title="导出" v-model="exportModel2" @on-ok="comfirmExport2" @on-cancel="backoutExport">
      <div>
        <p>是否确认导出结算？</p>
      </div>
    </Modal>
    <Modal
      class="finance-modal"
      v-model="receiveModal"
      title="添加收款项"
      @on-ok="receiveOk"
      @on-cancel="receiveCancel"
    >
      <div>
        <div class="finance-item">
          <p>收款日期:</p>
          <DatePicker v-model="receiveDate" format="yyyy-MM-dd" class="finance-item-input" />
        </div>
      </div>
      <div>
        <div class="finance-item">
          <p>收款金额:</p>
          <InputNumber v-model="receiveMoney" :min="0" class="finance-item-input" />
        </div>
      </div>
    </Modal>
    <Modal
      class="finance-modal"
      v-model="billModal"
      title="添加发票项"
      @on-ok="billOk"
      @on-cancel="billCancel"
    >
      <div>
        <div class="finance-item">
          <p>发票日期:</p>
          <DatePicker v-model="billDate" format="yyyy-MM-dd" class="finance-item-input" />
        </div>
      </div>
      <div>
        <div class="finance-item">
          <p>发票金额:</p>
          <InputNumber v-model="billMoney" :min="0" class="finance-item-input" />
        </div>
      </div>
    </Modal>
    <Modal
      class="finance-modal"
      v-model="rewardModal"
      title="添加奖金项"
      @on-ok="rewardOk"
      @on-cancel="rewardCancel"
    >
      <div>
        <div class="finance-item">
          <p>奖金日期:</p>
          <DatePicker v-model="rewardDate" format="yyyy-MM-dd" class="finance-item-input" />
        </div>
      </div>
      <div>
        <div class="finance-item">
          <p>奖金金额:</p>
          <InputNumber v-model="rewardMoney" :min="0" class="finance-item-input" />
        </div>
      </div>
      <div>
        <div class="finance-item">
          <p>毛产值奖金金额:</p>
          <InputNumber v-model="grossRewardMoney" :min="0" class="finance-item-input" />
        </div>
      </div>
    </Modal>
    <Modal
      class="finance-modal"
      v-model="accountModal"
      title="添加结算项"
      @on-ok="accountOk"
      @on-cancel="accountCancel"
    >
      <div>
        <div class="finance-item">
          <p>结算日期:</p>
          <DatePicker v-model="accountDate" format="yyyy-MM-dd" class="finance-item-input" />
        </div>
      </div>
      <div>
        <div class="finance-item">
          <p>结算金额:</p>
          <InputNumber v-model="accountMoney" :min="0" class="finance-item-input" />
        </div>
      </div>
    </Modal>

    <div class="top-button-group">
      <Button type="success" @click="openExportMdel1" :disabled="exportBton">导出</Button>
      <Button type="success" @click="openExportMdel2" :disabled="exportBton">导出结算</Button>
    </div>
    <div class="search-bar">
      <div class="senior-search-block">
        <Button v-if="clearHigh" type="warning" @click="HighClear">清除高级条件</Button>
        <Poptip trigger="focus" content="包含高级查询内容">
          <Input class="search-content" v-model="keyword" :disabled="highWinButton" />
        </Poptip>
        <Button type="default" @click="OpenhihgLevelSearch" :disabled="highWinButton">高级查询</Button>

        <Button type="primary" style @click="hihgLevelSearch" :disabled="highSearchBton">搜索</Button>
      </div>
    </div>
    <div>
      <Table
        height="500"
        stripe
        border
        :columns="columns"
        :data="data"
        @on-selection-change="selectChange"
      ></Table>
    </div>
    <br />
    <div>
      <Page :total="totalDataNo" @on-change="getpageNum" />
    </div>

    <transition name="bidding-detail">
      <div class="bidding-block" v-if="financeDtaildetail">
        <div class="bidding-block-top">
          <div class="bidding-block-close" @click="closefinacedtail">
            <!--左上角关闭动作-->
            <Icon type="md-close" />
          </div>
          <span>项目详情</span>
        </div>
        <div class="undertake-title">
          <button class="undertake-title" @click.prevent="which='easynews'">项目基本信息</button>
          <button class="undertake-title" @click.prevent="which='authorizenews'">编制信息</button>
          <button class="undertake-title" @click.prevent="which='finacenews'">财务信息</button>
          <button class="undertake-title" @click.prevent="which='projectprogress'">项目进展</button>
        </div>
        <keep-alive>
          <component v-bind:is="which" :callbackdata="callbackdata" :callbackState="callbackState"></component>
        </keep-alive>
        <div>
          <Button type="primary" @click="closefinacedtail">确定</Button>
        </div>
      </div>
    </transition>

    <transition name="finance-block">
      <div class="finance-block" v-if="financeBlock">
        <div class="finance-block-top">
          <div class="finance-block-close" @click="closeFinanceBlock">
            <Icon type="md-close" />
          </div>
          <span>财务信息</span>
        </div>
        <div class="finance-body">
          <div class="finance-title">
            <span>项目基本信息</span>
          </div>
          <div class="finance-content">
            <div class="finance-item">
              <p>合同归属单位:</p>
              <Input class="finance-item-input" v-model="contactOrigin" disabled />
            </div>
            <div class="finance-item">
              <p>项目经费:</p>
              <InputNumber :min="0" class="finance-item-input" v-model="projectFund" />
              <span class="finance-suffix">万元</span>
            </div>
            <div class="finance-item">
              <p>毛产值:</p>
              <InputNumber class="finance-item-input" :value="grossValue" disabled />
              <span class="finance-suffix">万元</span>
            </div>
          </div>
          <div class="finance-title">
            <span>外协费</span>
            <span class="finance-sum">总金额:{{ OutsourcingFeeAmount }}万</span>
          </div>
          <div class="finance-content">
            <div>
              <div class="finance-item">
                <p>检测费:</p>
                <InputNumber :min="0" v-model="OutsourcingFee[0]" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <div class="finance-item">
                <p>专家费:</p>
                <InputNumber :min="0" v-model="OutsourcingFee[1]" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <div class="finance-item">
                <p>会务费:</p>
                <InputNumber :min="0" v-model="OutsourcingFee[2]" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
            </div>
            <div>
              <div class="finance-item">
                <p>服务费:</p>
                <InputNumber :min="0" v-model="OutsourcingFee[3]" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <div class="finance-item">
                <p>其它费用:</p>
                <InputNumber :min="0" v-model="OutsourcingFee[4]" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <div class="finance-item">
                <p>业务开支有无:</p>
                <RadioGroup v-model="hasBSExpense">
                  <Radio label="有"></Radio>
                  <Radio label="无"></Radio>
                </RadioGroup>
              </div>
            </div>
          </div>
          <div class="finance-title">
            <span>收款信息</span>
            <span class="finance-sum">收款总金额:{{ receiveValue }}万</span>
            <Button type="primary" @click="addReceive">增加收款项</Button>
          </div>
          <div class="finance-content">
            <div class="finance-list-item" v-for="(item, index) in receiveList" :key="index">
              <div class="finance-item">
                <p>收款日期:</p>
                <DatePicker v-model="item.date" format="yyyy-MM-dd" class="finance-item-input" />
              </div>
              <div class="finance-item">
                <p>收款金额:</p>
                <InputNumber v-model="item.amount" :min="0" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <Button type="error" @click="deleteReceive(index)" ghost>删除</Button>
            </div>
          </div>
          <div class="finance-title">
            <span>发票信息</span>
            <span class="finance-sum">发票总金额:{{ billValue }}万</span>
            <Button type="primary" @click="addBill">增加发票项</Button>
          </div>
          <div class="finance-content">
            <div class="finance-list-item" v-for="(item, index) in billList" :key="index">
              <div class="finance-item">
                <p>发票日期:</p>
                <DatePicker v-model="item.date" format="yyyy-MM-dd" class="finance-item-input" />
              </div>
              <div class="finance-item">
                <p>发票金额:</p>
                <InputNumber v-model="item.amount" :min="0" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <Button type="error" @click="deleteBill(index)" ghost>删除</Button>
            </div>
          </div>
          <div class="finance-title">
            <span>奖金信息</span>
            <span class="finance-sum">奖金总金额:{{ rewardValue }}万</span>
            <span class="finance-sum">毛产值奖金总金额:{{ grassRewardValue }}万</span>
            <Button type="primary" @click="addReward">增加奖金项</Button>
          </div>
          <div class="finance-content">
            <div class="finance-list-item" v-for="(item, index) in rewardList" :key="index">
              <div class="finance-item">
                <p>奖金日期:</p>
                <DatePicker v-model="item.date" format="yyyy-MM-dd" class="finance-item-input" />
              </div>
              <div class="finance-item">
                <p>奖金金额:</p>
                <InputNumber v-model="item.amount" :min="0" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <div class="finance-item">
                <p>毛产值奖金金额:</p>
                <InputNumber v-model="item.grossAmount" :min="0" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <Button type="error" @click="deleteReward(index)" ghost>删除</Button>
            </div>
          </div>
          <div class="finance-title">
            <span>结算总金额</span>
            <span class="finance-sum">发票总金额:{{ accountValue }}万</span>
            <Button type="primary" @click="addAccount">增加结算项</Button>
          </div>
          <div class="finance-content">
            <div class="finance-list-item" v-for="(item, index) in accountList" :key="index">
              <div class="finance-item">
                <p>发票日期:</p>
                <DatePicker v-model="item.date" format="yyyy-MM-dd" class="finance-item-input" />
              </div>
              <div class="finance-item">
                <p>发票金额:</p>
                <InputNumber v-model="item.amount" :min="0" class="finance-item-input" />
                <span class="finance-suffix">万元</span>
              </div>
              <Button type="error" @click="deleteAccount(index)" ghost>删除</Button>
            </div>
          </div>
          <div class="finance-title">
            <span>备注</span>
          </div>
          <div class="finance-content">
            <Input type="areatext" v-model="remark" />
          </div>
          <div>
            <Button type="primary" @click="submitFinance">确定</Button>
            <Button @click="closeFinanceBlock">取消</Button>
          </div>
        </div>
      </div>
    </transition>

    <transition name="bidding-high">
      <div class="bidding-block" v-if="financeHigh">
        <Form ref="formHigh" :rules="ruleHigh" :model="equalConditions" :label-width="150">
          <div class="bidding-block-top">
            <div class="bidding-block-close" @click="cancelAdd">
              <!--左上角关闭动作-->
              <Icon type="md-close" />
            </div>
            <span>高级查询</span>
          </div>
          <div>
            <div class="bidding-body">
              <div class="bidding-content">
                <div class="panel panel-default bidding-title">
                  <div class="panel-heading">
                    <h4 class="panel-title">范围</h4>
                  </div>
                  <div class="panel-body">
                    <br />
                    <div>
                      <div class="bidding-item">
                        <FormItem label="收款日期范围从：">
                          <DatePicker type="date" v-model="rangeConditions[0].sta" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <span>至</span>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <DatePicker type="date" v-model="rangeConditions[0].end" />
                        </FormItem>
                      </div>
                    </div>
                    <div>
                      <div class="bidding-item">
                        <FormItem label="项目登记日期从：">
                          <DatePicker type="date" v-model="rangeConditions[1].sta" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <span>至</span>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <DatePicker type="date" v-model="rangeConditions[1].end" />
                        </FormItem>
                      </div>
                    </div>
                    <div>
                      <div class="bidding-item">
                        <FormItem label="发票日期范围从：">
                          <DatePicker type="date" v-model="rangeConditions[2].sta" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <span>至</span>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <DatePicker type="date" v-model="rangeConditions[2].end" />
                        </FormItem>
                      </div>
                    </div>
                    <div>
                      <div class="bidding-item">
                        <FormItem label="盖章日期范围从：">
                          <DatePicker type="date" v-model="rangeConditions[3].sta" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <span>至</span>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem :label-width="50">
                          <DatePicker type="date" v-model="rangeConditions[3].end" />
                        </FormItem>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="panel panel-default bidding-title">
                  <div class="panel-heading">
                    <h4 class="panel-title">类别</h4>
                  </div>
                  <div class="panel-body">
                    <br />
                    <div>
                      <div class="bidding-item">
                        <FormItem label="合同归属单位：">
                          <Select
                            v-model="equalConditions.contractOrigin"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in contactOrgOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="panel panel-default bidding-title">
                  <div class="panel-heading">
                    <h4 class="panel-title">状态</h4>
                  </div>
                  <div class="panel-body">
                    <br />
                    <div>
                      <div class="bidding-item">
                        <FormItem label="归档状态：">
                          <Select
                            v-model="equalConditions.hasArchived"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in backFileOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="结算状态：">
                          <Select
                            v-model="spAccount"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in accountOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="收款状态：">
                          <Select
                            v-model="spCollect"
                            style="width:200px"
                            clearable
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in collecOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>

                      <div class="bidding-item">
                        <FormItem label="盖章状态：">
                          <Select
                            v-model="equalConditions.hasUsualSealed"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in sealOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="发票状态：">
                          <Select
                            v-model="spInvoice"
                            style="width:200px"
                            clearable
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in invoiceOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="奖金状态：">
                          <Select
                            v-model="spReward"
                            style="width:200px"
                            clearable
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in rewardOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>

                      <div class="bidding-item">
                        <FormItem label="合同有无：">
                          <Select
                            v-model="equalConditions.hasContract"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in ifContactOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="业务开支：">
                          <Select
                            v-model="spOutput"
                            style="width:200px"
                            clearable
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in outputOption"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="panel panel-default bidding-title">
                  <div class="panel-heading">
                    <h4 class="panel-title">其他</h4>
                  </div>
                  <div class="panel-body">
                    <br />
                    <div>
                      <div class="bidding-item">
                        <FormItem label="项目名称：" prop="name">
                          <Input class="bidding-item-input" v-model="equalConditions.name" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="承接部门：">
                          <Select
                            v-model="equalConditions.undertakeDepartmentId"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in dptList"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="建设单位：" prop="developmentOrganization">
                          <Input
                            style="width:200px"
                            class="bidding-item-input"
                            v-model="equalConditions.developmentOrganization"
                          />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="编制人员：">
                          <Select
                            v-model="equalConditions.editPersonId"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in allPeo"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="承接人员：">
                          <Select
                            v-model="equalConditions.undertakePersonId"
                            clearable
                            style="width:200px"
                            :label-in-value="true"
                          >
                            <Option
                              v-for="item in allPeo"
                              :value="item.id"
                              :key="item.id"
                            >{{ item.name }}</Option>
                          </Select>
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="财务备注：" prop="eRemark">
                          <Input class="bidding-item-input" v-model="equalConditions.eRemark" />
                        </FormItem>
                      </div>
                      <div class="bidding-item">
                        <FormItem label="承接备注：" prop="undertakeRemark">
                          <Input
                            class="bidding-item-input"
                            v-model="equalConditions.undertakeRemark"
                          />
                        </FormItem>
                      </div>
                    </div>
                  </div>
                </div>

                <div></div>

                <div></div>

                <div></div>

                <div></div>

                <div></div>

                <div></div>

                <div></div>

                <div></div>

                <div>
                  <Button type="primary" @click="checkAdd('formHigh')">确定</Button>
                  <Button @click="cancelAdd">取消</Button>
                </div>
              </div>
            </div>
          </div>
        </Form>
      </div>
    </transition>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    //不含空格 非必填
    const validateSpace = (rule, value, callback) => {
      if (value) {
        const res = this.common.judgeSpachs(value);
        if (res === -1) {
          callback(new Error("不能含有空格"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    //数字+汉字+字母  非必填
    const validateLenNoCHLetter = (rule, value, callback) => {
      if (value != "") {
        const res = this.common.judgeNumberInput(value);
        if (res === -1) {
          callback(new Error("输入只能是汉字、英文或数字符号"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    return {
      exportModel1: false,
      exportModel2: false,
      row: {},
      pageNum: 1,
      pageSize: 10,
      modelId: 7,
      financeDtaildetail: false,
      which: "easynews",

      ruleHigh: {
        developmentOrganization: [
          //建设单位 数+英+汉
          { required: false, validator: validateLenNoCHLetter, trigger: "blur" }
        ],
        name: [
          //项目名称
          { required: false, validator: validateLenNoCHLetter, trigger: "blur" }
        ],
        undertakeRemark: [
          { required: false, validator: validateSpace, trigger: "blur" }
        ],
        eRemark: [
          { required: false, validator: validateSpace, trigger: "blur" }
        ]
      },

      //处理权限disabled
      exportBton: true,
      easySearchBton: true,
      highWinButton: true,
      highSearchBton: true,
      jurisdiction: null, //当前用户的权限
      jurisdictionNo: null, //1标识只有承接，2表示只有管理，3表示都有

      financeBlock: false,
      projectFund: 0, //项目经费
      OutsourcingFee: [0, 0, 0, 0, 0], //外协费列表
      hasBSExpense: "", //业务开支有无
      receiveModal: false,
      receiveDate: "",
      receiveMoney: 0,
      receiveList: [], //收款信息
      billModal: false,
      billDate: "",
      billMoney: 0,
      billList: [], //发票信息
      rewardModal: false,
      rewardDate: "",
      rewardMoney: 0,
      grossRewardMoney: 0,
      rewardList: [], //奖金信息
      accountModal: false,
      accountDate: "",
      accountMoney: "",
      accountList: [], //结算信息
      remark: "",
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "序号",
          key: "id",
          width: 100,
          fixed: "left"
        },
        // {
        //   title: "状态",
        //   width: 120,
        //   key: "state"
        // },
        {
          title: "操作",
          fixed: "right",
          width: 120,
          render: (h, params) => {
            let detailBton = true;
            let editBton = true;
            if (this.jurisdictionNo >= 1) {
              detailBton = false;
            }
            if (this.jurisdictionNo == 1 || this.jurisdictionNo == 3) {
              editBton = false;
            }
            return h(
              "Dropdown",
              {
                on: {
                  "on-click": name => {
                    let rowData = params.row;
                    let id = rowData.id;
                    let st = params.row.state;
                    if (name == "read") {
                      this.financeDtaildetail = true;
                      this.row = id;
                      this.setBackdata(st);
                    } else if (name == "finance") {
                      //点击修改财务信息
                      this.row = id;
                      this.getCOntactOrg();
                      this.getFinanceInfo();
                      this.financeBlock = true;
                    }
                  }
                },
                props: {
                  transfer: true
                }
              },
              [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary"
                    }
                  },
                  "操作>>"
                ),
                h(
                  "DropdownMenu",
                  {
                    slot: "list"
                  },
                  [
                    h(
                      "DropdownItem",
                      {
                        props: {
                          name: "read",
                          disabled: detailBton
                        }
                      },
                      "查看详情"
                    ),
                    h(
                      "DropdownItem",
                      {
                        props: {
                          name: "finance",
                          disabled: editBton
                        }
                      },
                      "修改财务信息"
                    )
                  ]
                )
              ]
            );
          }
        }
      ],
      data: [],

      foreignHelp: {
        checkFee: 0,
        professionFee: 0,
        meetingFee: 0,
        serviceFee: 0,
        otherFee: 0,
        businessFeeTag: null
      },

      contactOrigin: "",

      submitReceive: [],
      submitBill: [],
      submitReward: [],
      submitAccount: [],

      totalDataNo: null, //总共的数据个数

      allPeo: [], //所有人的名单
      allPeoPages: null,
      proType: [], //项目类别名单
      editPeo: [], //项目编制人员名单
      dptList: [], //所有部门列表
      carerType: [], //所有行业类别
      editPerList: [], //编制权限人名单
      backFileList: [], //归档人名单
      //////////////////////////////////////////////////////////////////
      financeHigh: false,
      clearHigh: false,

      equalConditions: {
        //单个字段list
        undertakeDepartmentId: null, //承接部门id
        hasArchived: null, //归档状态----
        name: null, //项目名称-----
        eRemark: null, //财务备注------
        editPersonId: null, //编制人员id------
        contractOrigin: null, //合同归属-----
        undertakeRemark: null, //承接备注------
        developmentOrganization: null, //建设单位---
        undertakePersonId: null, //承接人---
        hasUsualSealed: null, //盖章状态-----
        hasContract: null, //合同有无----
        businessFeeTag: null //业务开支----

        //共12个
      },
      rangeConditions: [
        //传给后端的时间，或金额字段
        {
          field: "collectionDate",
          sta: null,
          end: null
        },
        {
          field: "registDate",
          sta: null,
          end: null
        },
        {
          field: "invoiceDate",
          sta: null,
          end: null
        },
        {
          field: "usualSealDate",
          sta: null,
          end: null
        }
      ],
      specialConditions: [], //传给后端的特殊字段

      spCollect: null, //特殊收款状态v-model
      spInvoice: null, //特殊发票状态v-model
      spReward: null, //特殊奖金状态v-model
      spOutput: null, //特殊业务开支v-model，0或1直接赋值到list，2添加到特殊

      spAccount: null, //结算

      contactOrgOption: [
        //合同归属
        {
          id: "学校",
          name: "学校"
        },
        {
          id: "公司",
          name: "公司"
        }
      ],
      collecOption: [
        //收款状态
        {
          id: "collectionAmount=0",
          name: "尚无收款"
        },
        {
          id: "collectionAmount=fund",
          name: "已收款"
        },
        {
          id: "collectionAmount>0 and collectionAmount<fund",
          name: "部分收款"
        },
        {
          id: "collectionAmount=0 or collectionAmount<fund",
          name: "尚无收款及部分收款"
        },
        {
          id: "collectionAmount>0",
          name: "已收款及部分收款"
        }
      ],
      sealOption: [
        //盖章状态
        {
          id: 0,
          name: "未盖章"
        },
        {
          id: 1,
          name: "已盖章"
        }
      ],
      invoiceOption: [
        //发票状态
        {
          id: "invoiceAmount=0",
          name: "发票未开"
        },

        {
          id: "invoiceAmount>0 and invoiceAmount<fund",
          name: "发票部分开"
        },
        {
          id: "invoiceAmount>0 and invoiceAmount<=fund",
          name: "发票已开+部分开"
        },
        {
          id: "invoiceAmount=0 or (invoiceAmount > 0 and invoiceAmount<fund)",
          name: "发票未开+部分开"
        },
        {
          id: "invoiceAmount=fund and invoiceAmount!=0",
          name: "发票已开"
        }
      ],
      rewardOption: [
        //奖金状态
        {
          id: "rewardAmount=0",
          name: "尚无奖金"
        },
        {
          id: "rewardAmount=collectionAmount and rewardAmount!=0",
          name: "奖金等于收款"
        },
        {
          id: "rewardAmount>collectionAmount",
          name: "奖金多于收款"
        },
        {
          id: "rewardAmount<collectionAmount",
          name: "奖金少于收款"
        },
        {
          id: "rewardAmount<collectionAmount or rewardAmount=0",
          name: "尚无奖金且奖金少于收款"
        }
      ],
      ifContactOption: [
        //合同有无
        {
          id: 0,
          name: "无合同"
        },
        {
          id: 1,
          name: "有合同"
        }
      ],
      outputOption: [
        //业务开支
        {
          id: 0,
          name: "无"
        },
        {
          id: 1,
          name: "有"
        },
        {
          id: 2,
          name: "未处理"
        }
      ],
      contactStateOption: [
        //项目状态
        {
          id: 1,
          name: "正常"
        },
        {
          id: 0,
          name: "废弃"
        }
      ],
      backFileOption: [
        //归档状态
        {
          id: 1,
          name: "已归档"
        },
        {
          id: 0,
          name: "未归档"
        }
      ],
      accountOption: [
        {
          id: "settlementAmount=fund",
          name: "已结算"
        },
        {
          id: "settlementAmount<fund and settlementAmount <> 0",
          name: "部分结算"
        },
        {
          id: "settlementAmount=0",
          name: "未结算"
        }
      ],
      callbackState: {},
      ids: [],
      selectId: [],
      keyword: null,
      undertakeDPListName: null,
      undertakePRListName: null,
      regDate: null,
      rangeTag: null, //是否是全院
      totalHigh: null, //全院个数
      OutsourcingFeeAmount: null
    };
  },
  computed: {
    // outsourcingValue() {
    //   var OF = 0;
    //   var i=0;
    //   let objName1 = JSON.stringify(this.OutsourcingFee);
    //   let objName2 = JSON.parse(objName1);
    //   for(i=0;i<this.OutsourcingFee.length;i++){
    //     OF=OF+this.OutsourcingFee[i];
    //     console.log(objName2);
    //   }
    //   this.OutsourcingFee.forEach(e => {
    //     OF += e;
    //     console.log("fee",e);
    //   });
    //   return OF;
    // },
    grossValue() {
      return this.projectFund - this.OutsourcingFeeAmount;
    },
    receiveValue() {
      let RV = 0;
      this.receiveList.forEach(e => {
        //console.log(e);
        RV += e.amount;
      });
      return RV;
    },
    billValue() {
      let BV = 0;
      this.billList.forEach(e => {
        BV += e.amount;
      });
      return BV;
    },
    rewardValue() {
      let RV = 0;
      this.rewardList.forEach(e => {
        RV += e.amount;
      });
      return RV;
    },
    grassRewardValue() {
      let GRV = 0;
      this.rewardList.forEach(e => {
        GRV += e.grossAmount;
      });
      return GRV;
    },
    accountValue() {
      let AV = 0;
      this.accountList.forEach(e => {
        AV += e.amount;
      });
      return AV;
    }
  },
  beforeMount() {
    this.getNewData(); //产生表信息
    this.getcolumns(); //产生表头
    this.getdepartments(); //得到部门的name和ID
    this.getEditpersonList(); //编制人员
    this.getAllPeo(); //得到所有人
    this.getJurisdiction(); //获得当前用户的权限
  },
  methods: {
    backoutExport() {
      this.exportModel1 = false;
      this.exportModel2 = false;
    },
    comfirmExport1() {
      this.exportModel1 = false;
      this.exportList();
    },
    comfirmExport2() {
      this.exportModel2 = false;

      this.exportAccount();
    },
    
    openExportMdel1() {
      this.exportModel1=true;
    },
    openExportMdel2() {
      this.exportModel2=true;
    },
   
    getJurisdiction() {
      axios({
        method: "get",
        url: this.IP.IP + "/personInfo/getPermission"
      }).then(result => {
        this.jurisdiction = result.data.data;
        // console.log("权限", this.jurisdiction);
        var i = 0;
        var judge1 = 0;
        var judge2 = 0;
        for (i; i < this.jurisdiction.length; i++) {
          if (this.jurisdiction[i] == "财务") {
            judge1 = 1;
          }
          if (this.jurisdiction[i] == "管理") {
            judge2 = 1;
          }
        }
        if (judge1 == 1 && judge2 == 1) {
          this.jurisdictionNo = 3;
        } else if (judge1 != 1 && judge2 == 1) {
          this.jurisdictionNo = 2;
        } else if (judge1 == 1 && judge2 != 1) {
          this.jurisdictionNo = 1;
        } else {
          this.jurisdictionNo = -1;
        }
        // console.log("数字权限", this.jurisdictionNo);
        this.handleJurisdiction();
      });
    },
    //处理操作的disabled
    handleJurisdiction() {
      if (this.jurisdictionNo >= 1) {
        this.exportBton = false;
        this.easySearchBton = false;
        this.highWinButton = false;
        this.highSearchBton = false;
      } else {
        this.exportBton = true;
        this.easySearchBton = true;
        this.highWinButton = true;
        this.highSearchBton = true;
      }
    },
    selectChange: function(data) {
      //console.log(data);
      this.selectId = data;
    },
    downloadAccount(data) {
      if (!data) {
        return;
      }
      var blob = new Blob([data], {
        type:
          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
      });
      var url = window.URL.createObjectURL(data.data);
      var aLink = document.createElement("a");
      aLink.style.display = "none";
      aLink.href = url;
      aLink.setAttribute("download", "projectRegList.xls");
      document.body.appendChild(aLink);
      aLink.click();
      document.body.removeChild(aLink); //下载完成移除元素
      window.URL.revokeObjectURL(url);
    },
    realExportAccount() {
      // console.info("ids");
      //console.log(this.ids);
      axios({
        method: "post",
        url: this.IP.IP + "/undertake/exportRegList",
        data: {
          ids: this.ids,
          time: this.regDate,
          undertakeDepartmentName: this.undertakeDPListName,
          undertakePersonName: this.undertakePRListName
        },
        responseType: "blob"
      })
        .then(result => {
          // console.info("zong");
          //console.log(result);
          this.downloadAccount(result);
          this.ids = [];
          this.undertakeDPListName = null;
          this.undertakePRListName = null;
          this.regDate = null;
          this.selectId = [];
          this.$Spin.hide();
        })
        .catch(error => {});
    },
    exportAccount() {
      this.$Spin.show({
        render: h => {
          return h("div", [
            h("Icon", {
              class: "demo-spin-icon-load",
              props: {
                type: "ios-loading",
                size: 18
              }
            }),
            h("div", "Loading")
          ]);
        }
      });
      if (this.selectId.length > 0) {
        var i = 0;
        for (i = 0; i < this.selectId.length; i++) {
          this.ids.push(this.selectId[i].id);
        }
        // console.info("1");
        //console.log(this.ids);
        this.setTreeCondition();
        this.realExportAccount();
      } else {
        this.$ajax({
          method: "post",
          url: this.IP.IP + "/table/superSearchIds",
          data: {
            equalConditions: this.equalConditions,
            rangeConditions: this.rangeConditions,
            specialConditions: this.specialConditions
            //keyWord:this.keyword
          }
        }).then(result => {
          // console.info("2");
          //console.log(result.data.data)
          this.ids = result.data.data;
          this.setTreeCondition();
          this.realExportAccount();
        });
      }
    },
    setTreeCondition() {
      this.undertakeDPListName = "全部";
      this.undertakePRListName = "全部";
      if (this.rangeConditions[1].sta) {
        this.regDate = this.rangeConditions[1].sta;
      } else if (!this.rangeConditions[1].end) {
        this.regDate = "全部";
      }
      if (this.rangeConditions[1].end) {
        this.regDate = this.regDate + "至" + this.rangeConditions[1].end;
      }
    },
    downloadList(data) {
      if (!data) {
        return;
      }
      var blob = new Blob([data], {
        type:
          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
      });
      var url = window.URL.createObjectURL(data.data);
      var aLink = document.createElement("a");
      aLink.style.display = "none";
      aLink.href = url;
      aLink.setAttribute("download", "FinState.xls");
      document.body.appendChild(aLink);
      aLink.click();
      document.body.removeChild(aLink); //下载完成移除元素
      window.URL.revokeObjectURL(url);
    },
    realExportList() {
      // console.info("ids");
      //console.log(this.ids);
      axios({
        method: "post",
        url: this.IP.IP + "/finance/exportFinState",
        data: {
          ids: this.ids,
          time: this.regDate
        },
        responseType: "blob"
      })
        .then(result => {
          // console.info("zong");
          //console.log(result);
          this.downloadList(result);
          this.ids = [];
          this.undertakeDPListName = null;
          this.undertakePRListName = null;
          this.regDate = null;
          this.selectId = [];
          this.$Spin.hide();
        })
        .catch(error => {});
    },
    exportList() {
      this.$Spin.show({
        render: h => {
          return h("div", [
            h("Icon", {
              class: "demo-spin-icon-load",
              props: {
                type: "ios-loading",
                size: 18
              }
            }),
            h("div", "Loading")
          ]);
        }
      });
      if (this.selectId.length > 0) {
        var i = 0;
        for (i = 0; i < this.selectId.length; i++) {
          this.ids.push(this.selectId[i].id);
        }
        // console.info("1");
        //console.log(this.ids);
        this.setTreeCondition();
        this.realExportList();
      } else {
        this.$ajax({
          method: "post",
          url: this.IP.IP + "/table/superSearchIds",
          data: {
            equalConditions: this.equalConditions,
            rangeConditions: this.rangeConditions,
            specialConditions: this.specialConditions
            //keyWord:this.keyword
          }
        }).then(result => {
          // console.info("2");
          //console.log(result.data.data)
          this.ids = result.data.data;
          this.setTreeCondition();
          this.realExportList();
        });
      }
    },
    getCOntactOrg() {
      axios({
        method: "get",
        url: this.IP.IP + "/undertake/getUndertake?projectId=" + this.row
      }).then(result => {
        ////console.log(this.row);
        this.contactOrigin = result.data.data.contractOrigin;
      });
    },
    getFinanceInfo() {
      axios({
        method: "get",
        url: this.IP.IP + "/finance/getFinance?projectId=" + this.row
      }).then(result => {
        console.log(result.data.data.collections);
        this.projectFund = result.data.data.fund;
        this.receiveList = result.data.data.collections;
        this.billList = result.data.data.invoices;
        this.rewardList = result.data.data.rewards;
        this.accountList = result.data.data.settlements;
        var tag = result.data.data.foreignHelp.businessFeeTag;
        var checkfee = result.data.data.foreignHelp.checkFee;
        var professionFee = result.data.data.foreignHelp.professionFee;
        var meetingFee = result.data.data.foreignHelp.meetingFee;
        var serviceFee = result.data.data.foreignHelp.serviceFee;
        var otherFee = result.data.data.foreignHelp.otherFee;
        this.OutsourcingFee[0] = checkfee;
        this.OutsourcingFee[1] = professionFee;
        this.OutsourcingFee[2] = meetingFee;
        this.OutsourcingFee[3] = serviceFee;
        this.OutsourcingFee[4] = otherFee;
        for (var i = 0; i < this.OutsourcingFee.length; i++) {
          this.OutsourcingFeeAmount += this.OutsourcingFee[i];
          console.log(this.OutsourcingFeeAmount);
        }
        if (tag) {
          this.hasBSExpense = "有";
        } else {
          this.hasBSExpense = "无";
        }
      });
    },
    getNewData() {
      this.data = [];

      // console.info("select123");
      //console.log(this.select1);
      //console.log(this.select2);
      //console.log(this.select3);
      this.$ajax({
        method: "post",
        url: this.IP.IP + "/table/show",
        params: {
          pageNum: 1,
          pageSize: 10,
          modelId: 7
        }
      }).then(response => {
        this.data = response.data.data.data.list;
        //console.info('111');
        ////console.log(fields);
        var total = response.data.data.data.total;
        this.totalDataNo = total;
        // console.info("total");
        //console.log(this.totalDataNo);
      });
    },
    DateToString(date) {
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      if (month < 10) {
        var newmonth = "0" + month;
        month = newmonth;
      }
      if (day < 10) {
        var newday = "0" + day;
        day = newday;
      }
      var sDate = year + "-" + month + "-" + day;
      return sDate;
    },
    setConditionNull() {
      var i = 0;
      if (!this.keyword) {
        this.keyword = null;
      }
      for (i = 0; i < this.rangeConditions.length; i++) {
        if (!this.rangeConditions[i].sta) {
          this.rangeConditions[i].sta = null;
        }
        if (!this.rangeConditions[i].end) {
          this.rangeConditions[i].end = null;
        }
      }
      for (i = 0; i < this.rangeConditions.length; i++) {
        if (this.rangeConditions[i].sta) {
          this.rangeConditions[i].sta = this.DateToString(
            this.rangeConditions[i].sta
          );
        }
        if (this.rangeConditions[i].end) {
          this.rangeConditions[i].end = this.DateToString(
            this.rangeConditions[i].end
          );
        }
      }
      if (!this.equalConditions.developmentOrganization) {
        //建设单位
        this.equalConditions.developmentOrganization = null;
      }

      if (!this.equalConditions.hasArchived) {
        //归档状态
        if (this.equalConditions.hasArchived != 0) {
          this.equalConditions.hasArchived = null;
        }
      }
      if (!this.equalConditions.editPersonId) {
        //编制人id
        this.equalConditions.editPersonId = null;
      }
      if (!this.equalConditions.undertakeDepartmentId) {
        //承接部门id
        this.equalConditions.undertakeDepartmentId = null;
      }

      if (!this.equalConditions.name) {
        //项目名称
        this.equalConditions.name = null;
      }

      if (!this.equalConditions.contractOrigin) {
        //合同归属单位
        this.equalConditions.contractOrigin = null;
      }
      if (!this.equalConditions.hasUsualSealed) {
        //盖章状态
        if (this.equalConditions.hasUsualSealed != 0) {
          this.equalConditions.hasUsualSealed = null;
        }
      }
      if (!this.equalConditions.hasContract) {
        //合同有无
        if (this.equalConditions.hasContract != 0) {
          this.equalConditions.hasContract = null;
        }
      }
      if (!this.equalConditions.businessFeeTag) {
        //业务开支有无
        if (this.equalConditions.businessFeeTag != 0) {
          this.equalConditions.businessFeeTag = null;
        }
      }
      if (!this.equalConditions.eRemark) {
        //财务备注
        this.equalConditions.eRemark = null;
      }
      if (!this.equalConditions.undertakeRemark) {
        //承接备注
        this.equalConditions.undertakeRemark = null;
      }
      if (!this.equalConditions.undertakePersonId) {
        //承接人
        this.equalConditions.undertakePersonId = null;
      }
    },
    ClearCondition() {
      var i = 0;
      this.keyword = null;
      for (i = 0; i < this.rangeConditions.length; i++) {
        this.rangeConditions[i].sta = null;
        this.rangeConditions[i].end = null;
      }
      this.equalConditions.undertakeDepartmentId = null;
      this.equalConditions.hasArchived = null;
      this.equalConditions.name = null;
      this.equalConditions.eRemark = null;
      this.equalConditions.editPersonId = null;
      this.equalConditions.contractOrigin = null;
      this.equalConditions.undertakeRemark = null;
      this.equalConditions.developmentOrganization = null;
      this.equalConditions.undertakePersonId = null;
      this.equalConditions.hasUsualSealed = null;
      this.equalConditions.hasContract = null;
      this.equalConditions.businessFeeTag = null;
      this.specialConditions = [];
      this.spCollect = null;
      this.spInvoice = null;
      this.spReward = null;
      this.spOutput = null;
      this.spAccount = null;
    },
    HighClear() {
      this.ClearCondition();
      this.clearHigh = false;
    },
    cancelAdd() {
      this.financeHigh = false;
    },
    addSpecial() {
      //添加进speciall
      // console.info("yewu");
      //console.log(this.spOutput);
      this.specialConditions = [];
      if (this.spCollect) {
        //处理收款
        this.specialConditions.push(this.spCollect);
      }
      if (this.spInvoice) {
        //处理发票
        this.specialConditions.push(this.spInvoice);
      }
      if (this.spReward) {
        //处理奖金
        this.specialConditions.push(this.spReward);
      }
      if (this.spAccount) {
        //处理结算
        this.specialConditions.push(this.spAccount);
      }
      if (this.spOutput) {
        //处理业务开支
        if (this.spOutput == 2) {
          this.equalConditions.businessFeeTag = null;
          // console.info("111");
          this.specialConditions.push("businessFeeTag is null");
        } else {
          // console.info("222");
          this.equalConditions.businessFeeTag = this.spOutput;
        }
      } else if (this.spOutput == 0) {
        // console.info("222");
        this.equalConditions.businessFeeTag = this.spOutput;
      } else {
        this.equalConditions.businessFeeTag = null;
      }
    },
    checkAdd1() {
      this.setConditionNull(); //空字符串变null
      this.addSpecial();
      this.financeHigh = false;
      this.clearHigh = true;
    },
    checkAdd(name) {
      //高级查询点确定
      // console.info("equal");
      // console.log(this.equalConditions);
      this.$refs[name].validate(valid => {
        if (valid) {
          this.setConditionNull(); //空字符串变null
          this.addSpecial();
          this.financeHigh = false;
          this.clearHigh = true;
        } else {
          this.$Message.error("格式错误!");
        }
      });
    },
    OpenhihgLevelSearch() {
      this.financeHigh = true;
    },
    hihgLevelSearch() {
      var u = this.IP.IP + "/table/superSearch";
      if (this.keyword) {
        u = this.IP.IP + "/table/superSearch?keyWord=" + this.keyword;
        this.checkAdd1();
      }
      this.pageNum = 1;
      this.$ajax({
        method: "post",
        url: u,
        params: {
          pageNum: this.pageNum,
          pageSize: 10,
          modelId: 7
        },
        data: {
          equalConditions: this.equalConditions,
          rangeConditions: this.rangeConditions,
          specialConditions: this.specialConditions
        }
      }).then(result => {
        if (result.data.code == 0) {
          // console.info("高级查询结果");
          //console.log(result);
          this.data = result.data.data.data.list;
          var total = result.data.data.data.total;
          this.totalDataNo = total;
        } else {
          this.data = [];
          var msg = result.data.msg;
          this.$Message.error(msg);
        }
      });
    },
    hihgLevelSearch1() {
      var u = this.IP.IP + "/table/superSearch";
      if (this.keyword) {
        u = this.IP.IP + "/table/superSearch?keyWord=" + this.keyword;
      }
      this.$ajax({
        method: "post",
        url: u,
        params: {
          pageNum: this.pageNum,
          pageSize: 10,
          modelId: 7
        },
        data: {
          equalConditions: this.equalConditions,
          rangeConditions: this.rangeConditions,
          specialConditions: this.specialConditions
        }
      }).then(result => {
        if (result.data.code == 0) {
          // console.info("高级查询结果");
          //console.log(result);
          this.data = result.data.data.data.list;
          //  var total = result.data.data.data.total;
          //  this.totalDataNo = total;
        } else {
          this.data = [];
          var msg = result.data.msg;
          this.$Message.error(msg);
        }
      });
    },
    getpageNum(e) {
      // console.info("当前页");
      //console.log(e);
      this.pageNum = e;
      if (this.clearHigh) {
        this.hihgLevelSearch1();
      } else {
        this.getNewData1();
      }
    },
    getNewData1() {
      this.data = [];

      this.$ajax({
        method: "post",
        url: this.IP.IP + "/table/show",
        params: {
          pageNum: this.pageNum,
          pageSize: 10,
          modelId: 7
        }
      }).then(response => {
        this.data = response.data.data.data.list;
      });
    },
    getdepartments() {
      axios({
        method: "get",
        url: this.IP.IP + "/getDepartments"
      }).then(result => {
        // console.info("部门信息");
        //console.log(result);
        var data = result.data.data;

        var i = 0;
        for (i = 0; i < data.length; i++) {
          this.setNode(data[i]);
        }
      });
    },
    setNode(node) {
      if (node != null) {
        node.name = node.nodeDepartmentIndex.name;
        node.id = node.nodeDepartmentIndex.id;
        node.children = node.childrenDepartmentIndexes;
        this.dptList.push({
          id: node.id + "",
          name: node.name
        });
        var i = 0;
        for (i = 0; i < node.childrenDepartmentIndexes.length; i++) {
          this.setNode(node.childrenDepartmentIndexes[i]);
        }
      }
    },
    insertPeo() {
      // console.info("insetr");
      //console.log(this.allPeoPages);
      var i = 1;
      for (i = 1; i <= this.allPeoPages; i++) {
        axios({
          method: "get",
          url: this.IP.IP + "/personInfo/show?pageNum=" + i + "&pageSize=" + 10
        }).then(result => {
          var total = result.data.data.list.length;
          var list = result.data.data.list;
          // console.info("lentgh");
          // console.info(total);
          //console.log(list);
          for (var j = 0; j < total; j++) {
            this.allPeo.push({
              id: list[j].id + "",
              name: list[j].name + ""
            });
            // console.info(i);
            // //console.log(this.allPeo);
          }
        });
      }
      // console.info("所有人名单");
      //console.log(this.allPeo);
    },
    getAllPeo() {
      axios({
        method: "get",
        url: this.IP.IP + "/personInfo/show?pageNum=" + 1 + "&pageSize=" + 10
      }).then(result => {
        this.allPeoPages = result.data.data.pages;
        // console.info("pages111");
        //console.log(this.allPeoPages);
        this.insertPeo();
      });
      //this.insertPeo();
    },
    getEditpersonList() {
      axios({
        method: "get",
        url: this.IP.IP + "/personInfo/getEditPerson"
      }).then(result => {
        var total = result.data.data.length;
        var list = result.data.data;
        for (var i = 0; i < total; i++) {
          this.editPerList.push({
            id: list[i].personId + "",
            name: list[i].personName + ""
          });
        }
        // console.info("编制人名单");
        //console.log(this.editPerList);
      });
    },
    getcolumns() {
      axios({
        method: "post",
        url:
          this.IP.IP +
          "/table/show?pageNum=" +
          this.pageNum +
          "&pageSize=" +
          this.pageSize +
          "&modelId=" +
          this.modelId
      }).then(result => {
        let that = this;

        var fields = result.data.data.fields;
        var attribute = result.data.data.attribute;
        //var list=result.data.data.data.list;
        var i = 0;
        //console.log(result);
        for (i; i < fields.length; i++) {
          this.columns.push({
            title: fields[i],
            width: 160,
            key: attribute[i]
          });
        }
        //this.data=list;
      });
    },
    getTable() {
      axios({
        method: "post",
        url:
          this.IP.IP +
          "/table/show?pageNum=" +
          this.pageNum +
          "&pageSize=" +
          this.pageSize +
          "&modelId=" +
          this.modelId
      }).then(result => {
        let that = this;

        //var fields=result.data.data.fields;
        //var attribute=result.data.data.attribute;
        var list = result.data.data.data.list;
        //var i=0;
        //console.log(result);
        // for(i;i<fields.length;i++){
        //   this.columns.push({
        //     title:fields[i],
        //     key:attribute[i]
        //   })
        // }
        this.data = list;
      });
    },
    closefinacedtail() {
      let that = this;
      this.$Modal.confirm({
        title: "确定关闭吗？",
        onOk() {
          that.financeDtaildetail = false;
        }
      });
    },
    setBackdata(st) {
      this.callbackdata = this.row;
      this.callbackState = st;
    },
    closeFinanceBlock() {
      let that = this;
      this.$Modal.confirm({
        title: "确定不提交吗？",
        onOk() {
          that.financeBlock = false;
          that.projectFund = 0;
          that.OutsourcingFee = [0, 0, 0, 0, 0]; //外协费列表
          that.OutsourcingFeeAmount = null;
          that.hasBSExpense = ""; //业务开支有无
          that.receiveDate = "";
          that.receiveMoney = 0;
          that.receiveList = []; //收款信息
          that.billDate = "";
          that.billMoney = 0;
          that.billList = []; //发票信息
          that.rewardDate = "";
          that.rewardMoney = 0;
          that.grossRewardMoney = 0;
          that.rewardList = []; //奖金信息
          that.accountDate = "";
          that.accountMoney = "";
          that.accountList = [];
          that.remark = "";
        }
      });
    },
    deleteReceive(index) {
      let that = this;
      this.$Modal.confirm({
        title: "确认删除这一项吗？",
        onOk() {
          that.receiveList.splice(index, 1);
        }
      });
    },
    addReceive() {
      this.receiveModal = true;
    },
    receiveOk() {
      this.receiveList.push({
        date: this.receiveDate,
        amount: this.receiveMoney
      });
      this.receiveCancel();
      ////console.log(this.receiveValue());
    },
    receiveCancel() {
      this.receiveDate = "";
      this.receiveMoney = 0;
    },
    deleteBill(index) {
      let that = this;
      this.$Modal.confirm({
        title: "确认删除这一项吗？",
        onOk() {
          that.billList.splice(index, 1);
        }
      });
    },
    addBill() {
      this.billModal = true;
    },
    billOk() {
      this.billList.push({
        date: this.billDate,
        amount: this.billMoney
      });
      this.billCancel();
    },
    billCancel() {
      this.billDate = "";
      this.billMoney = 0;
    },
    deleteReward(index) {
      let that = this;
      this.$Modal.confirm({
        title: "确认删除这一项吗？",
        onOk() {
          that.rewardList.splice(index, 1);
        }
      });
    },
    addReward() {
      this.rewardModal = true;
    },
    rewardOk() {
      this.rewardList.push({
        date: this.rewardDate,
        amount: this.rewardMoney,
        grossAmount: this.grossRewardMoney
      });
      this.rewardCancel();
    },
    rewardCancel() {
      this.rewardDate = "";
      this.rewardMoney = 0;
      this.grossRewardMoney = 0;
    },
    deleteAccount(index) {
      let that = this;
      this.$Modal.confirm({
        title: "确认删除这一项吗？",
        onOk() {
          that.accountList.splice(index, 1);
        }
      });
    },
    addAccount() {
      this.accountModal = true;
    },
    accountOk() {
      this.accountList.push({
        date: this.accountDate,
        amount: this.accountMoney
      });
      this.accountCancel();
    },
    accountCancel() {
      this.accountDate = "";
      this.accountMoney = 0;
    },
    submitFinance() {
      //console.log(this.receiveList);
      //console.log(this.billList);
      //console.log(this.rewardList);
      //console.log(this.accountList);
      var i = 0;
      // //console.log(this.receiveList[0].date);
      // //console.log(this.receiveList[0].date instanceof Date);
      // var ss=this.DateToString(this.receiveList[0].date);
      // //console.log(ss);
      // //console.log(ss instanceof Date);
      //console.log("changdu"+this.receiveList.length);
      for (i = 0; i < this.receiveList.length; i++) {
        if (this.receiveList[i].date instanceof Date) {
          var d = this.DateToString(this.receiveList[i].date);
          var a = this.receiveList[i].amount;
          this.submitReceive.push({ date: d, amount: a });
        }
      }
      for (i = 0; i < this.billList.length; i++) {
        if (this.billList[i].date instanceof Date) {
          var d = this.DateToString(this.billList[i].date);
          var a = this.billList[i].amount;
          this.submitBill.push({ date: d, amount: a });
        }
      }
      for (i = 0; i < this.rewardList.length; i++) {
        if (this.rewardList[i].date instanceof Date) {
          var d = this.DateToString(this.rewardList[i].date);
          var a = this.rewardList[i].amount;
          var g = this.rewardList[i].grossAmount;
          this.submitReward.push({ date: d, amount: a, grossAmount: g });
        }
      }
      for (i = 0; i < this.accountList.length; i++) {
        if (this.accountList[i].date instanceof Date) {
          var d = this.DateToString(this.accountList[i].date);
          var a = this.accountList[i].amount;
          this.submitAccount.push({ date: d, amount: a });
        }
      }
      this.insetForeHelp();
      this.submitAddInfo();
      // //console.log(this.submitReceive);
      // //console.log(this.submitBill);
      // //console.log(this.submitReward);
      // //console.log(this.submitAccount);
    },
    insetForeHelp() {
      this.foreignHelp.checkFee = this.OutsourcingFee[0];
      this.foreignHelp.professionFee = this.OutsourcingFee[1];
      this.foreignHelp.meetingFee = this.OutsourcingFee[2];
      this.foreignHelp.serviceFee = this.OutsourcingFee[3];
      this.foreignHelp.otherFee = this.OutsourcingFee[4];
      if (this.hasBSExpense == "有") {
        this.foreignHelp.businessFeeTag = true;
      } else if (this.hasBSExpense == "无") {
        this.foreignHelp.businessFeeTag = false;
      }
      // console.info("fore");
      //console.log(this.OutsourcingFee);
      //console.log(this.foreignHelp);
      //console.log(this.projectFund);
      //console.log(this.contactOrigin);
      //console.log(this.submitReceive);
      //console.log(this.submitBill);
      //console.log(this.submitReward);
      //console.log(this.submitAccount);
      //console.log(this.remark);
    },
    setNull() {
      this.submitReceive = [];
      this.submitBill = [];
      this.submitReward = [];
      this.submitAccount = [];
      this.contactOrigin = null;
      this.projectFund = null;
      this.foreignHelp.checkFee = 0;
      this.foreignHelp.professionFee = 0;
      this.foreignHelp.meetingFee = 0;
      this.foreignHelp.serviceFee = 0;
      this.foreignHelp.otherFee = 0;
      this.foreignHelp.businessFeeTag = null;

      this.projectFund = 0;
      this.OutsourcingFee = [0, 0, 0, 0, 0]; //外协费列表
      this.OutsourcingFeeAmount = null;
      this.hasBSExpense = ""; //业务开支有无
      this.receiveDate = "";
      this.receiveMoney = 0;
      this.receiveList = []; //收款信息
      this.billDate = "";
      this.billMoney = 0;
      this.billList = []; //发票信息
      this.rewardDate = "";
      this.rewardMoney = 0;
      this.grossRewardMoney = 0;
      this.rewardList = []; //奖金信息
      this.accountDate = "";
      this.accountMoney = "";
      this.accountList = [];
      this.remark = "";
    },
    submitAddInfo() {
      this.$ajax({
        method: "post",
        url: this.IP.IP + "/finance/editFinance",
        params: {
          projectId: this.row
        },
        data: {
          fund: this.projectFund,
          //contractOrigin:this.contactOrigin,
          invoices: this.submitBill,
          collections: this.submitReceive,
          rewards: this.submitReward,
          settlements: this.submitAccount,
          foreignHelp: this.foreignHelp,
          remark: this.remark
        }
      }).then(result => {
        // console.info("确定新建");
        //console.log(result);
        var code = "";
        code = result.data.code;
        var msg = result.data.msg;
        if (code == 0) {
          this.$Message.success("修改财务成功");
        } else {
          this.$Message.error(msg);
        }
        this.financeBlock = false;
        this.setNull();
      });
    },
    DateToString(date) {
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      if (month < 10) {
        var newmonth = "0" + month;
        month = newmonth;
      }
      if (day < 10) {
        var newday = "0" + day;
        day = newday;
      }
      var sDate = year + "-" + month + "-" + day;
      return sDate;
    }
  }
};
</script>

<style>
.top-button-group {
  padding: 5px;
}
.search-bar {
  width: 100%;
}
.search-block {
  padding: 5px;
  display: inline-block;
  width: 300px;
  height: 50px;
}
.search-block span {
  line-height: 50px;
}
.search-block .ivu-select {
  width: 150px;
}
.senior-search-block {
  height: 50px;
  padding: 5px;
}
.search-content {
  width: 200px;
}
/* finance-block动画 */
.finance-block-enter-active,
.finance-block-leave-active {
  transition: all 0.3s ease;
}
.finance-block-enter,
.finance-block-leave-to {
  transform: scale(0.9);
  opacity: 0;
}
.finance-block {
  z-index: 1010;
  overflow-y: auto;
  left: 0;
  top: 0;
  position: fixed;
  width: 100%;
  height: 100%;
  background: #efefef;
}
.finance-body {
  padding: 10px;
}
.finance-modal {
  z-index: 1051;
}
.finance-block-top {
  font-size: 15px;
  border-bottom: 1px solid #cdcdcd;
  background: #efefef;
}
.finance-block-close {
  cursor: pointer;
  display: inline-block;
  border-right: 1px solid #cdcdcd;
  font-size: 20px;
  padding: 0 5px;
}
.finance-title {
  margin: 10px 5px;
  font-size: 15px;
  padding: 5px;
  color: #000000;
  border-bottom: 1px solid #cdcdcd;
}
.finance-content {
  padding: 10px 5px;
  border-bottom: 1px dashed #cdcdcd;
}
.finance-item {
  display: inline-block;
}
.finance-item p {
  display: inline-block;
  width: 100px;
}
.finance-suffix {
  margin-right: 5px;
}
.ivu-input[disabled],
.ivu-input-number-input[disabled] {
  color: #000000;
}
.finance-item-input {
  width: 200px;
}
.finance-sum {
  margin-left: 10px;
  font-weight: bold;
  color: #27a9e3;
}
.finance-list-item {
  margin-bottom: 5px;
}
</style>